Skip to content

Conversation

@khvn26
Copy link
Member

@khvn26 khvn26 commented Oct 21, 2025

Thanks for submitting a PR! Please check the boxes below:

  • I have added information to docs/ if required so people know about the feature!
  • I have filled in the "Changes" section below?
  • I have filled in the "How did you test this code" section below?
  • I have used a Conventional Commit title for this Pull Request

Changes

This PR migrates the API documentation from drf-yasg to drf-spectacular to provide an OpenAPI 3.0 compliant schema, addressing issue #6183 and building on PR #6184.

Key changes include:

  • Replaced drf-yasg with drf-spectacular for schema generation and UI.
  • Introduced new schema and docs endpoints while maintaining backward compatibility for existing /swagger.json, /swagger.yaml, and /docs/ paths.
  • Configured drf-spectacular settings, including security schemes and permissions.
  • Updated serializer fields (e.g., EdgeFeatureField) to use drf-spectacular's @extend_schema_field for union types.
  • Fixed an edge case in CreateUpdateEnvironmentSerializer to guard self.instance access.
  • Added drf-spectacular to pyproject.toml.

How did you test this code?

I tested this code manually by:

  1. Accessing the new OpenAPI 3 schema: GET /api/v1/docs/?format=openapi
  2. Verifying the new Swagger UI: GET /api/v1/docs/
  3. Confirming backward compatibility for existing schema endpoints:
    • GET /api/v1/swagger.json
    • GET /api/v1/swagger.yaml
  4. Checking the new dedicated schema endpoint: GET /api/v1/schema/

Open in Cursor Open in Web

Replace drf-yasg UI/schema endpoints with drf-spectacular while retaining
compatibility routes. Keep drf-yasg dependency for existing annotations,
convert critical custom schema bits to OAS3 (anyOf) and fix serializer edge case.
This enables /api/v1/docs/?format=openapi to return a valid OpenAPI 3 schema
consumable by generators (resolves #6183).
@cursor
Copy link

cursor bot commented Oct 21, 2025

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@vercel
Copy link

vercel bot commented Oct 21, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
flagsmith-frontend-preview Ready Ready Preview Comment Oct 22, 2025 3:39pm
flagsmith-frontend-staging Ready Ready Preview Comment Oct 22, 2025 3:39pm
1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
docs Ignored Ignored Preview Oct 22, 2025 3:39pm

@github-actions github-actions bot added the api Issue related to the REST API label Oct 21, 2025
@khvn26
Copy link
Member Author

khvn26 commented Oct 22, 2025

@cursor make the tests green. Use Cursor's Github app access to view test checks result. If you choose to run the tests yourself, use make test opts='-k <pytest filter>' and make test opts='--lf'. to isolate the test run to failing tests.

@cursor
Copy link

cursor bot commented Oct 22, 2025

❌ Unable to add follow-up after multiple attempts. The agent may be experiencing issues.

Please try again later or check the agent status.


Open in Cursor Open in Web

Learn more about Cursor Agents

@khvn26
Copy link
Member Author

khvn26 commented Oct 22, 2025

Okay, Cursor's background agent is unresponsive now. I want to keep this work in a background agent, so we might hold this off until we start trying Claude Code out. CC @matthewelwell

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api Issue related to the REST API

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants